<%@ page import="java.util.ArrayList" %>
<%@ page import="com.po.MyTools" %>
<%@ page import="com.po.GoodsSingle" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:useBean id="myCart" class="com.po.ShopCart" scope="session"/>
<%
    String action=request.getParameter("action");
    if(action==null){
        action="";
    }
    if(action.equals("buy")){
        ArrayList goodslist = (ArrayList) session.getAttribute("goodslist");
        int id = MyTools.str2int(request.getParameter("id"));
        GoodsSingle single = (GoodsSingle) goodslist.get(id);
        myCart.addItem(single);
        response.sendRedirect("show.jsp");
    }else if (action.equals("remove")){
        String name=request.getParameter("name");
        myCart.removeItem(name);
        response.sendRedirect("shopcart.jsp");
    }else if (action.equals("clear")){
        myCart.clearCar();
        response.sendRedirect("show.jsp");
    }else {
        response.sendRedirect("show.jsp");
    }
%>
